Binary Arithmetic and Adders
Binary arithmetic is the hardware language behind counters, timers, address generators, CPUs, DSP blocks, and FPGA datapaths. The same ideas used to add two 4-bit numbers in a classroom scale directly to 32-bit microcontrollers and 64-bit processors.
Learning Objectives
By the end of this lesson, you should be able to:
- Add unsigned binary numbers and track carries.
- Explain half adders, full adders, ripple-carry adders, and carry look-ahead adders.
- Use two's-complement arithmetic for signed addition and subtraction.
- Detect unsigned carry and signed overflow correctly.
- Estimate adder delay and choose an adder structure for a practical design.
Binary Addition Rules
Binary addition has only four single-bit cases:
| A | B | Sum | Carry |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
The last row is the important one: 1 + 1 = 10b, so the sum bit is 0 and the carry into the next column is 1.
Worked Example: 11 + 6
carries: 1 1 1 .
1 0 1 1 (11 decimal)
+ 0 1 1 0 (6 decimal)
---------
1 0 0 0 1 (17 decimal)
The rightmost bit is the least significant bit. Carries move from right to left, exactly like decimal addition.
Half Adder
A half adder adds two input bits, A and B. It produces a sum bit S and a carry bit C.
| A | B | S | C |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
The equations are:
$$
S = A \oplus B
$$
$$
C = A \cdot B
$$
The half adder is useful for the least significant stage when there is no incoming carry. It is not enough for the middle stages of a multi-bit adder because those stages must also add a carry from the previous bit.
Full Adder
A full adder adds three one-bit values: A, B, and carry-in Cin.
| A | B | Cin | S | Cout |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
The sum is the odd-parity function:
$$
S = A \oplus B \oplus C_{in}
$$
The carry-out is 1 when at least two inputs are 1:
$$
C_{out} = A B + C_{in}(A \oplus B)
$$
Equivalent majority form:
$$
C_{out} = AB + AC_{in} + BC_{in}
$$
Ripple-Carry Adder
The simplest multi-bit adder chains full adders. Each carry-out becomes the carry-in of the next more significant bit.
Ripple adders are compact and easy to understand. Their weakness is delay: the most significant sum bit cannot settle until the carry has passed through all lower stages.
If one full-adder carry stage has delay tFA, an approximate worst-case delay for an n-bit ripple adder is:
$$
t_{ripple} \approx n \cdot t_{FA}
$$
Example: a 32-bit ripple adder with tFA = 0.8 ns has a worst-case carry delay near 25.6 ns. That is too slow for many high-speed CPUs, but it may be fine in a small microcontroller peripheral or low-speed FPGA control path.
Carry Look-Ahead
Carry look-ahead adders reduce delay by computing carry signals from generate and propagate terms.
For bit i:
$$
G_i = A_iB_i
$$
$$
P_i = A_i \oplus B_i
$$
Gi means the bit position generates a carry by itself. Pi means it will propagate an incoming carry.
For a 4-bit block, the carry terms expand from the recurrence Cnext = G + P Cin:
$$
C_1 = G_0 + P_0C_0
$$
$$
C_2 = G_1 + P_1G_0 + P_1P_0C_0
$$
The next two carry equations continue the same pattern:
C3 = G2 + P2 C2
C4 = G3 + P3 C3
Expanded forms are useful for gate-level design, but on small screens the recurrence is easier to read and is usually how engineers reason about a carry-look-ahead block before generating the full logic.
Carry look-ahead uses more gates and wiring, but the carry computation is much shallower than ripple carry. Real processors often use hierarchical adders such as carry look-ahead, carry select, Brent-Kung, or Kogge-Stone structures.
Unsigned Carry vs Signed Overflow
Do not confuse carry with overflow. They answer different questions.
| Flag | Applies To | Meaning |
|---|---|---|
Carry C |
Unsigned arithmetic | Result exceeded the available bit width |
Overflow V |
Signed two's-complement arithmetic | Result is outside signed range |
For unsigned 4-bit addition, 1111 + 0001 = 1_0000. The lower 4 bits are 0000 and carry is 1, meaning the correct unsigned result needs 5 bits.
For signed 4-bit two's-complement addition, the range is -8 to +7. Adding 0110 (+6) and 0101 (+5) gives 1011, which looks like -5. That is signed overflow because two positive inputs produced a negative output.
Signed overflow can be detected by:
$$
V = C_{in,MSB} \oplus C_{out,MSB}
$$
It can also be detected from signs: overflow occurs when the input sign bits match and the result sign bit is different. In Boolean form, use same input signs AND result sign changed.
Two's-Complement Subtraction
Two's complement represents signed numbers using the same adder hardware as unsigned arithmetic.
For an n-bit number:
$$
\text{range} = -2^{n-1} \text{ to } 2^{n-1}-1
$$
To negate a number:
- Invert every bit.
- Add
1.
Example: find -5 in 4 bits.
+5 = 0101
invert 1010
add 1 1011
-5 = 1011
Subtraction becomes addition:
$$
A - B = A + (\overline{B} + 1)
$$
In hardware, an adder/subtractor usually XORs each B bit with a subtract control signal and uses the same signal as the carry-in.
When SUB = 0, the circuit adds A + B. When SUB = 1, it adds A + not(B) + 1, which is A - B.
Binary Multiplication Basics
Binary multiplication is repeated shift-and-add. If a multiplier bit is 1, add a shifted copy of the multiplicand. If it is 0, add zero.
Example: 1011b x 1101b = 11 x 13.
1011
x 1101
------
1011
0000.
1011..
1011...
--------
10001111 (143 decimal)
Hardware multipliers use many adders. Small controllers may use sequential shift-add hardware. DSPs, CPUs, and FPGAs often use parallel multiplier structures or dedicated DSP blocks.
Practical Design Checks
- Size the result correctly. Adding two
n-bit unsigned numbers can requiren+1bits. - Use signed types only when the signal is truly signed.
- Check both carry and overflow in CPU flag examples.
- In HDL, declare widths explicitly; accidental truncation is a common source of bugs.
- For FPGA datapaths, pipeline wide adders when the timing report shows carry-chain delay near the clock limit.
Common Mistakes
- Treating
Coutas signed overflow. - Forgetting to discard the final carry in fixed-width two's-complement subtraction.
- Mixing signed and unsigned values without extending the sign bit.
- Estimating ripple delay from average cases instead of worst-case carry propagation.
- Writing HDL expressions where the result width silently follows the narrowest operand.
Practice
- Add
10110101b + 01011110band show the carry chain. - Find the 8-bit two's complement of
01101001b. - Compute
0110b - 1001busing 4-bit two's-complement arithmetic. - A 16-bit ripple adder has
tFA = 1.2 ns. Estimate worst-case carry delay. - Decide whether each case has unsigned carry, signed overflow, both, or neither:
0111+0001,1111+0001,1000+1000.
Summary
Binary adders are built from simple logic, but the design details matter. Half adders handle two bits, full adders add carry-in, ripple adders are compact but delay grows with width, and carry look-ahead reduces delay by computing carries in parallel. Two's-complement arithmetic lets the same adder perform signed addition and subtraction, provided you interpret carry and overflow correctly.
Further Reading
- M. Morris Mano and Michael Ciletti, Digital Design, sections on arithmetic circuits.
- David A. Patterson and John L. Hennessy, Computer Organization and Design, arithmetic chapter.
- Texas Instruments SN74HC283 and SN74LS181 datasheets for practical TTL/CMOS adder and ALU examples.
- IEEE Std 1800 SystemVerilog LRM sections on expression sizing and signed arithmetic.